<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <canvas id="myCanvas" width="300" height="200"></canvas>  
</body>

</html>
<script>  

// 假设有一个数组
let array = [1, 2, 3, 4, 5, 6, 7, 8, 9];
 
// 要替换的起始索引和结束索引
let startIndex = 6;
let endIndex = 8;
 
// 要插入的新元素
let newElements = [10, 11, 12];
 
// 使用splice进行替换
array.splice(startIndex+1, endIndex - startIndex-1, ...newElements);
 
console.log(array); // 输出: [1, 2, 3, 10, 11, 12, 7, 8, 9]
</script>